#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
	int N = 0;
	scanf("%d", &N);
	int arr1[100] = { 0 };
	int arr2[100] = { 0 };
	int i = 0;
	for (i = 0; i < N; i++)
	{
		scanf("%d", &arr1[i]);
		arr2[i] = arr1[i];
	}
	int num = 0;
	scanf("%d", &num);
	for (i = 0; num > arr1[i]; i++)
	{
		if (i == N)
		{
			arr1[N] = num;
			printf("%d ", arr1[i]);
			goto OK;
		}
		else printf("%d ", arr1[i]);
	}

	if (num < arr1[i])
	{
		arr1[i] = num;
		printf("%d ", arr1[i]);
	}
	for (i += 1; i <= N; i++)
	{
		arr1[i] = arr2[i - 1];
		printf("%d ", arr1[i]);
	}
OK:
	return 0;
}